package net.tcp;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;

/**
 * TCP的发送端
 * @author Administrator
 *
 */
public class TCPSender {

	public static void main(String[] args) throws UnknownHostException, IOException {
		System.out.println("客户端启动了");
		
		// 创建客户端
		Socket socket = new Socket("localhost", 8888);
		
		// 准备发送的数据
		String content = "我是一条消息";
		
		// 发送
		OutputStream outputStream = socket.getOutputStream(); // 输出流
		outputStream.write(content.getBytes());
	
		// 关闭资源
		outputStream.close();
		socket.close();
		
	}
}
